﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 低频天线阵列相控阵信号发生系统SmartFASK12.Models;

namespace 低频天线阵列相控阵信号发生系统SmartFASK12.Controls
{
    public class MPublic
    {
        /// <summary>
        /// 配置文件地址
        /// </summary>
        public static string ConfigFilePath = System.Environment.CurrentDirectory + "\\Config.Json";

        /// <summary>
        /// SmartFASK12文件地址
        /// </summary>
        public static string SmartFASK12FilePath = System.Environment.CurrentDirectory + "\\SmartFASK12.Json";

        /// <summary>
        /// USmartDPRO20文件地址
        /// </summary>
        public static string USmartDPRO20FilePath = System.Environment.CurrentDirectory + "\\USmartDPRO20.Json";

        private static ConfigModel _configModel = null;
        /// <summary>
        /// 配置文件
        /// </summary>
        public static ConfigModel ConfigModel
        {
            get
            {
                if (File.Exists(ConfigFilePath) && _configModel == null)
                {
                    string Json = File.ReadAllText(ConfigFilePath);
                    _configModel = JsonConvert.DeserializeObject<ConfigModel>(Json);
                }
                return _configModel;
            }
            set
            {
                _configModel = value;
                string json = JsonConvert.SerializeObject(_configModel, Formatting.Indented);
                File.WriteAllText(ConfigFilePath, json);
            }
        }

        /// <summary>
        /// 配置文件地址2
        /// </summary>
        public static string ConfigFilePath2 = System.Environment.CurrentDirectory + "\\Config2.Json";

        private static ConfigModel2 _configModel2 = null;
        /// <summary>
        /// 配置文件2
        /// </summary>
        public static ConfigModel2 ConfigModel2
        {
            get
            {
                if (File.Exists(ConfigFilePath2) && _configModel2 == null)
                {
                    string Json = File.ReadAllText(ConfigFilePath2);
                    _configModel2 = JsonConvert.DeserializeObject<ConfigModel2>(Json);
                }
                return _configModel2;
            }
            set
            {
                _configModel2 = value;
                string json = JsonConvert.SerializeObject(_configModel2, Formatting.Indented);
                File.WriteAllText(ConfigFilePath2, json);
            }
        }

        /// <summary>
        /// 颜色集合
        /// </summary>
        public static List<Color> Colors = new List<Color>()
        {
            Color.Black,
            Color.Blue,
            Color.Lime,
            Color.MidnightBlue,
            Color.Indigo,
            Color.SlateBlue,
            Color.Maroon,
            Color.MediumVioletRed,
            Color.Crimson,
            Color.Khaki,
            Color.Gold,
            Color.Thistle,
            Color.Navy,
            Color.LawnGreen,
            Color.Chocolate,
            Color.LightCoral
        };
    }
}
